package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlBandwidth;
import com.ruoyi.hualian.service.IHlBandwidthService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 带宽Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/bandwidth")
public class HlBandwidthController extends BaseController
{
    @Autowired
    private IHlBandwidthService hlBandwidthService;

    /**
     * 查询带宽列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:bandwidth:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlBandwidth hlBandwidth)
    {
        startPage();
        List<HlBandwidth> list = hlBandwidthService.selectHlBandwidthList(hlBandwidth);
        return getDataTable(list);
    }

    /**
     * 导出带宽列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:bandwidth:export')")
    @Log(title = "带宽", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlBandwidth hlBandwidth)
    {
        List<HlBandwidth> list = hlBandwidthService.selectHlBandwidthList(hlBandwidth);
        ExcelUtil<HlBandwidth> util = new ExcelUtil<HlBandwidth>(HlBandwidth.class);
        util.exportExcel(response, list, "带宽数据");
    }

    /**
     * 获取带宽详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:bandwidth:query')")
    @GetMapping(value = "/{bandwidthId}")
    public AjaxResult getInfo(@PathVariable("bandwidthId") Long bandwidthId)
    {
        return success(hlBandwidthService.selectHlBandwidthByBandwidthId(bandwidthId));
    }

    /**
     * 新增带宽
     */
    @PreAuthorize("@ss.hasPermi('hualian:bandwidth:add')")
    @Log(title = "带宽", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlBandwidth hlBandwidth)
    {
        return toAjax(hlBandwidthService.insertHlBandwidth(hlBandwidth));
    }

    /**
     * 修改带宽
     */
    @PreAuthorize("@ss.hasPermi('hualian:bandwidth:edit')")
    @Log(title = "带宽", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlBandwidth hlBandwidth)
    {
        return toAjax(hlBandwidthService.updateHlBandwidth(hlBandwidth));
    }

    /**
     * 删除带宽
     */
    @PreAuthorize("@ss.hasPermi('hualian:bandwidth:remove')")
    @Log(title = "带宽", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bandwidthIds}")
    public AjaxResult remove(@PathVariable Long[] bandwidthIds)
    {
        return toAjax(hlBandwidthService.deleteHlBandwidthByBandwidthIds(bandwidthIds));
    }
}
